import {
	observer
} from 'mobx-react';
import {
	WeaLocaleProvider,
} from 'ecCom';
import {
	Loading,
} from '../../public/learn';
import NoLinkageForm from './NoLinkageForm';
import PreInfo from './PreInfo';
import CollapseForm from './CollapseForm';
import LinkageForm from './LinkageForm';
import Title from './Title';
const getLabel = WeaLocaleProvider.getLabel;

@observer
export default class DialogContent extends React.Component {
	constructor(props) {
		super(props);
	}

	getDialogContent = () => {
		const {
			store,
			isMain,
			loading,
			formContainer,
		} = this.props, {
			cPage,
			preInfo,
			step,
			isDialogRenderCollapseForm,
			twoForm,
			threeForm,
			modify,
			linkage,
			onFormChange,
			onFormBlur,
			groupLinkage,
			readonly,
		} = store, {
			currentIndex
		} = step, {
			form
		} = formContainer;

		if (loading) {
			return <Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@o0suz4`} />;
		}

		if (cPage === 'main') {
			return (
				<div className='preInfo'>
					<PreInfo ecId={`${this && this.props && this.props.ecId || ''}_PreInfo@16ks9q`} preInfo={preInfo}/>
				</div>
			)
		}

		if (isMain) {
			if (isDialogRenderCollapseForm) {
				if (cPage === 'recordInfo') {
					return (
						<div className={`record-info ${readonly === '1' && `tip`}`}>
							<div>
								<Title ecId={`${this && this.props && this.props.ecId || ''}_Title@soiexm`} title={getLabel(505827,'本人信息')} clickEventListener={modify} readonly={readonly}/>
								<NoLinkageForm ecId={`${this && this.props && this.props.ecId || ''}_NoLinkageForm@h8xhry`} form={twoForm.form} isEdit='0'/>
							</div>
							<LinkageForm ecId={`${this && this.props && this.props.ecId || ''}_LinkageForm@dh5lr2`} {...threeForm} linkage={linkage} groupLinkage={groupLinkage} onFormChange={onFormChange}/>
						</div>
					)
				} else {
					return <CollapseForm ecId={`${this && this.props && this.props.ecId || ''}_CollapseForm@oihn2h`} form={form} onFormChange={onFormChange}/>
				}
			} else {
				return (
					<div className='form'>
						<NoLinkageForm ecId={`${this && this.props && this.props.ecId || ''}_NoLinkageForm@xd167e`} form={form} onFormChange={onFormChange} onBlur={onFormBlur}/>
					</div>
				)
			}
		} else {
			return (
				<div className='form'>
					<NoLinkageForm ecId={`${this && this.props && this.props.ecId || ''}_NoLinkageForm@zb9tss`} form={form} onBlur={onFormBlur}/>
				</div>
			)
		}
	}

	render() {
		return (
			<div className='dialog'>{this.getDialogContent()}</div>
		);
	}
}